<HTML>

<BODY BGCOLOR="#CCCCCC">

<CENTER>

<H1>PHP/MapScript module test</H1>
<P>
 
<?php
//
// This example opens a regular MapServer .MAP file, renders the main
// Map image (with the default layers enabled), the legend and the 
// scale bar, and displays them in the HTML output.
//

//
// Load MapScript module.
//
if (PHP_OS == "WINNT" || PHP_OS == "WIN32")
{
  dl("php_mapscript.dll");
}
else
{
  dl("php_mapscript.so");
}

// 
// Load MapServer .map file
//
// You can download the MapServer demo data from http://mapserver.gis.umn.edu/
//
$map = ms_newMapObj("gmap75.map");

// print $map->numlayers;
// phpinfo();
 
//
// RENDER MAIN MAP
//
// Note: If you get errors with the saveWebImage() call below, then make sure
// that the directory specified by IMAGEPATH in the .MAP file exists and is
// writable by the httpd user.
//
$img = $map->draw();

$url = $img->saveWebImage();
printf("<IMG SRC=%s WIDTH=%d HEIGHT=%d>\n", $url, $map->width, $map->height);
 
//
// LEGEND
//
$img = $map->drawLegend();
$url = $img->saveWebImage();
printf("<P>Draw into one picture.<BR><IMG SRC=%s>\n", $url);

// Draw all legend icon from all class in all layers
printf("<P>Draw each icon seperatly.<BR>");
printf("<TABLE BGCOLOR=WHITE>");
for ($i=0; $i<$map->numlayers; $i++)
{
    $layer = $map->getLayer($i);

    if ($layer->status != MS_OFF && $layer->type != MS_LAYER_QUERY)
      for ($j=0; $j<$layer->numclasses; $j++)
      {
          $myClass = $layer->GetClass($j);
        
          $img = $myClass->createLegendIcon($map->keysizex, $map->keysizey);
          $url = $img->saveWebImage();
          
          printf("<TR><TD><IMG SRC=%s></TD><TD>%s</TD></TR>", $url, $myClass->name);
      }
}
printf("</TABLE>");



//
// SCALE BAR
//
$img = $map->drawScaleBar();
$url = $img->saveWebImage();
printf("<P><IMG SRC=%s>\n", $url);
 
?>
 
</BODY>
</HTML>

